package com.wjyf.reducing_bento.controller;

import com.wjyf.reducing_bento.annotation.AuthCheck;
import com.wjyf.reducing_bento.common.BaseResponse;
import com.wjyf.reducing_bento.common.ResultUtils;
import com.wjyf.reducing_bento.model.entity.Reward;
import com.wjyf.reducing_bento.service.RewardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

import static com.wjyf.reducing_bento.constant.UserConstant.ADMIN;

/**
 * @description:
 * @author：lrk
 * @date: 2023/4/30
 */
@RestController
@RequestMapping("reward")
@Api(tags = "奖励")
public class RewardController {

    @Resource
    private RewardService rewardService;

    @GetMapping
    @ApiOperation("获取奖励佣金")
    @AuthCheck(mustRole = ADMIN)
    public BaseResponse get(){
        Reward rewardInfo = rewardService.getRewardInfo();
        return ResultUtils.success(rewardInfo);
    }

    @PutMapping("/{amount}")
    @ApiOperation("修改奖励佣金")
    @AuthCheck(mustRole = ADMIN)
    public BaseResponse put(@PathVariable BigDecimal amount){
        rewardService.setRewardInfo(amount);
        return ResultUtils.success(null);
    }
}
